package com.DHH.Controller.map;

import com.DHH.Dto.Message;
import com.DHH.Dto.VisibleArea;
import com.DHH.Entity.Device.BikeLatest;
import com.DHH.Entity.Device.Device;
import com.DHH.Entity.Device.DeviceArea;
import com.DHH.Mapper.Device.BikeLatestMapper;
import com.DHH.Mapper.Device.DeviceAreaMapper;
import com.DHH.Mapper.Public.MapMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

@Controller
@RequestMapping("/Admin/Map/")
public class MapController {
    @Autowired
    private MapMapper mapMapper;
    @Autowired
    private BikeLatestMapper bikeLatestMapper;
    @RequestMapping("/queryDeviceAreaAll")
    @ResponseBody
    public List<DeviceArea> queryDeviceAreaAll(VisibleArea visibleArea)
    {
        try {
            List<DeviceArea> list=mapMapper.selectDeeviceArea(visibleArea);
            return list;
        }catch (Exception e)
        {
            e.printStackTrace();
            return new ArrayList<DeviceArea>();
        }
    }
    @RequestMapping("/queryDeviceAll")
    @ResponseBody
    public List<Device> queryDeviceAll(VisibleArea visibleArea)
    {
        try {
            List<Device> list=mapMapper.selectDevice(visibleArea);
            return list;
        }catch (Exception e)
        {
            e.printStackTrace();
            return new ArrayList<Device>();
        }
    }
    @RequestMapping("/querybikeLatest")
    @ResponseBody
    public Message queryDeviceAll(BikeLatest  bikeLatest)
    {
        Message message=new Message();
        try {
          message.setData(bikeLatestMapper.selectOne(bikeLatest));
          message.setState(true);
          return message;
        }catch (Exception e)
        {
            message.setMsg("查无设备");
           return  message;
        }
    }
}
